$.Dialog.loading();
$.ajax({
    url: storelisturl.getArealist,
    type:"get",
    dataType:"json",
    success:function(data){
        $("#filiale").html("");
        if(data){
            $.each(data, function(index, row){
                var option = $("<option></option>");
                option.text(row.com_area_name);
                option.attr('value', row.com_area_code);
                $("#filiale").append(option);
            });
            getStorelist(138, '厚街');
        }
        $.Dialog.close();
    }
});
function getStorelist(areaid, text){
    if(text){
        $("#storename").text(text);
    }
    $.Dialog.loading();
    $.ajax({
        url: storelisturl.getStorelist + "&areaid="+areaid,
        type:"get",
        dataType:"json",
        success:function(data){
            $("#storelist").html("");
            if(data){
                $.each(data, function(index, row){
                    if(row.com_md_type01!=4){
                        var div = $('<div class="block_content_bg p_10 mt_10"></div>');
                        div.append('<p class="title">' + row.com_zip_name + '</p>');
//                    div.append('<p><a href="http://apis.map.qq.com/uri/v1/marker?marker=coord:' + row.com_md_lat + ',' + row.com_md_long + ';title:' + row.com_md_add + ';addr:' + row.com_md_add + ' target="_blank">地址：' + row.com_md_add + '</a></p>');
                        div.append('<p><a href="http://api.map.baidu.com/marker?location=' + row.com_md_lat + ',' + row.com_md_long + '&title=' + row.com_md_add + '&name=' + row.com_md_add + '&content=' + row.com_md_add + '&output=html&src=dggy" target="_blank">地址：' + row.com_md_add + '</a></p>');
                        div.append('<p><a href="tel:' + row.com_md_tel + '">电话：' + row.com_md_tel + '</a></p>');
                        $("#storelist").append(div);
                    }

                })
            }
            $.Dialog.close();
        }
    });
};

$('#searchmdtxt')
    .bind('focus', function(){
        if($(this).hasClass('watermark')){
            $(this).val('');
            $(this).removeClass('watermark');
        }
    }).bind('blur', function(){
        if(!$(this).val()){
            $(this).val('输入名称筛选门店');
            $(this).addClass('watermark');
        }
    }).bind('input propertychange',function(){
        var mdlist = $('#storelist .block_content_bg');
        if(!$(this).val()){
            mdlist.show();
        }
        else{
            mdlist.hide();
            $('#storelist .block_content_bg p.title:contains("' + $(this).val() + '")').parent().show();
        }
    });

//wx.config(wxconfig);
//wx.ready(function () {
//    wx.checkJsApi({
//        jsApiList: [
//            'getNetworkType',
//            'previewImage'
//        ],
//        success: function (res) {
////            alert(JSON.stringify(res));
//        }
//    });
//    var shareObj = {
//        title: 'aaa',
//        desc: 'vvv',
//        link: 'www.baidu.com',
//        imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
//        trigger: function (res) {
//            alert('用户点击发送给朋友');
//        },
//        success: function (res) {
//            alert('已分享');
//        },
//        cancel: function (res) {
//            alert('已取消');
//        },
//        fail: function (res) {
//            alert(JSON.stringify(res));
//        }
//    };
//    //分享朋友
//    wx.onMenuShareAppMessage(shareObj);
//    //分享朋友圈
//    wx.onMenuShareTimeline(shareObj);
//});
//wx.error(function(res){
//    alert("验证失败："  +JSON.stringify(res));
//});